#C compiler
CC       := /home/zamnedix/local/1/bin/gcc
#Compiler flags
CFLAGS   := -Wall -Og -march=native -pipe -g -Isqlite3
#Where system libraries are found
SYSRPATH := /lib:/lib/x86_64-linux-gnu:/usr/lib:/usr/lib/x86_64-linux-gnu
#Where CMS libraries go (prepended to the binary RPATHs)
RPATH    := /var/www/libs
#Where CGI binaries go
WWWROOT  := /var/www/html
#User to own content
WWWUSER  := www-data
#Group to own content
WWWGROUP := www-data
#dSFMT exponent
MEXP     := 521

.PHONY: auth sqlite index install

cms:
	${CC} ${CFLAGS} -DDSFMT_MEXP=${MEXP} list.c util.c dSFMT.c auth.c cms.c -o index -L. -lbcrypt -lb64 -lsqlite3 -lpthread -ldl -Wl,--rpath=${RPATH}:${SYSRPATH}
install:
	chown ${WWWUSER}:${WWWGROUP} *.so index
	chmod 755 *.so index
	cp *.so ${RPATH}
	cp index ${WWWROOT}
testget:
	DEBUG="YES" REQUEST_METHOD="GET" QUERY_STRING="n=1&data=foobar" ./index
	@echo
testpost:
	DEBUG="YES" REQUEST_METHOD="POST" INPUT_LENGTH=20 ./index
	@echo
